<?php

namespace App\Entities\Base;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * App\Entities\Base\Vulnerability
 *
 * @ORM\MappedSuperclass
 * @ORM\Table(name="`vulnerabilities`", indexes={@ORM\Index(name="vulnerabilities_asset_fk", columns={"`asset_id`"}), @ORM\Index(name="vulnerabilities_file_fk", columns={"`file_id`"})})
 */
class Vulnerability extends AbstractEntity
{
    /** Table name constant */
    const TABLE_NAME = 'vulnerabilities';

    /** Column name constants */
    const ID_FROM_SCANNER             = 'id_from_scanner';
    const NAME                        = 'name';
    const SEVERITY                    = 'severity';
    const PCI_SEVERITY                = 'pci_severity';
    const MALWARE_AVAILABLE           = 'malware_available';
    const MALWARE_DESCRIPTION         = 'malware_description';
    const IMPACT                      = 'impact';
    const CVSS_SCORE                  = 'cvss_score';
    const DESCRIPTION                 = 'description';
    const SOLUTION                    = 'solution';
    const GENERIC_OUTPUT              = 'generic_output';
    const ATTACK_TYPE                 = 'attack_type';
    const POC                         = 'poc';
    const HTTP_PORT                   = 'http_port';
    const PUBLISHED_DATE_FROM_SCANNER = 'published_date_from_scanner';
    const MODIFIED_DATE_FROM_SCANNER  = 'modified_date_from_scanner';
    const THUMBNAIL_1                 = 'thumbnail_1';
    const THUMBNAIL_2                 = 'thumbnail_2';
    const THUMBNAIL_3                 = 'thumbnail_3';
    const FILE_ID                     = 'file_id';
    const COMMENTS                    = 'comments';
    const JIRAISSUES                  = 'jiraIssues';
    const VULNERABILITYREFERENCECODES = 'vulnerabilityReferenceCodes';
    const VULNERABILITYHTTPDATA       = 'vulnerabilityHttpData';
    const FILE                        = 'file';

    /**
     * @ORM\Id
     * @ORM\Column(name="`id`", type="integer", options={"unsigned":true})
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(name="`id_from_scanner`", type="string", length=100, nullable=true)
     */
    protected $id_from_scanner;

    /**
     * @ORM\Column(name="`name`", type="string", length=255)
     */
    protected $name;

    /**
     * @ORM\Column(name="`severity`", type="decimal", precision=4, scale=2, nullable=true, options={"unsigned":true})
     */
    protected $severity;

    /**
     * @ORM\Column(name="`pci_severity`", type="decimal", precision=4, scale=2, nullable=true, options={"unsigned":true})
     */
    protected $pci_severity;

    /**
     * @ORM\Column(name="`malware_available`", type="boolean", nullable=true, options={"unsigned":true})
     */
    protected $malware_available;

    /**
     * @ORM\Column(name="`malware_description`", type="string", length=255, nullable=true)
     */
    protected $malware_description;

    /**
     * @ORM\Column(name="`impact`", type="string", length=255, nullable=true)
     */
    protected $impact;

    /**
     * @ORM\Column(name="`cvss_score`", type="decimal", precision=4, scale=2, nullable=true, options={"unsigned":true})
     */
    protected $cvss_score;

    /**
     * @ORM\Column(name="`description`", type="text", nullable=true)
     */
    protected $description;

    /**
     * @ORM\Column(name="`solution`", type="text", nullable=true)
     */
    protected $solution;

    /**
     * @ORM\Column(name="`generic_output`", type="text", nullable=true)
     */
    protected $generic_output;

    /**
     * @ORM\Column(name="`attack_type`", type="string", nullable=true)
     */
    protected $attack_type;

    /**
     * @ORM\Column(name="`poc`", type="text", nullable=true)
     */
    protected $poc;

    /**
     * @ORM\Column(name="`http_port`", type="integer", nullable=true, options={"unsigned":true})
     */
    protected $http_port;

    /**
     * @ORM\Column(name="`published_date_from_scanner`", type="datetime", nullable=true)
     */
    protected $published_date_from_scanner;

    /**
     * @ORM\Column(name="`modified_date_from_scanner`", type="datetime", nullable=true)
     */
    protected $modified_date_from_scanner;

    /**
     * @ORM\Column(name="`thumbnail_1`", type="text", nullable=true)
     */
    protected $thumbnail_1;

    /**
     * @ORM\Column(name="`thumbnail_2`", type="text", nullable=true)
     */
    protected $thumbnail_2;

    /**
     * @ORM\Column(name="`thumbnail_3`", type="text", nullable=true)
     */
    protected $thumbnail_3;

    /**
     * @ORM\Column(name="`file_id`", type="integer", nullable=true, options={"unsigned":true})
     */
    protected $file_id;

    /**
     * @ORM\Column(name="`created_at`", type="datetime")
     */
    protected $created_at;

    /**
     * @ORM\Column(name="`updated_at`", type="datetime")
     */
    protected $updated_at;

    /**
     * @ORM\OneToMany(targetEntity="Comment", mappedBy="vulnerability", cascade={"persist"})
     * @ORM\JoinColumn(name="`id`", referencedColumnName="`vulnerability_id`", nullable=false, onDelete="CASCADE")
     */
    protected $comments;

    /**
     * @ORM\OneToMany(targetEntity="JiraIssue", mappedBy="vulnerability", cascade={"persist"})
     * @ORM\JoinColumn(name="`id`", referencedColumnName="`vulnerability_id`", nullable=false, onDelete="CASCADE")
     */
    protected $jiraIssues;

    /**
     * @ORM\OneToMany(targetEntity="VulnerabilityReferenceCode", mappedBy="vulnerability", cascade={"persist"})
     * @ORM\JoinColumn(name="`id`", referencedColumnName="`vulnerability_id`", nullable=false, onDelete="CASCADE")
     */
    protected $vulnerabilityReferenceCodes;

    /**
     * @ORM\OneToMany(targetEntity="VulnerabilityHttpData", mappedBy="vulnerability", cascade={"persist","merge"})
     * @ORM\JoinColumn(name="`id`", referencedColumnName="`vulnerability_id`", nullable=false, onDelete="CASCADE")
     */
    protected $vulnerabilityHttpData;

    /**
     * @ORM\ManyToOne(targetEntity="File", inversedBy="vulnerabilities", cascade={"persist"})
     * @ORM\JoinColumn(name="`file_id`", referencedColumnName="`id`", onDelete="CASCADE")
     */
    protected $file;

    public function __construct()
    {
        $this->comments                    = new ArrayCollection();
        $this->jiraIssues                  = new ArrayCollection();
        $this->vulnerabilityReferenceCodes = new ArrayCollection();
        $this->vulnerabilityHttpData       = new ArrayCollection();
    }

    /**
     * Set the value of id.
     *
     * @param integer $id
     * @return \App\Entities\Base\Vulnerability
     */
    public function setId($id)
    {
        $this->id = $id;

        return $this;
    }

    /**
     * Get the value of id.
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set the value of id_from_scanner.
     *
     * @param string $id_from_scanner
     * @return \App\Entities\Base\Vulnerability
     */
    public function setIdFromScanner($id_from_scanner)
    {
        $this->id_from_scanner = $id_from_scanner;

        return $this;
    }

    /**
     * Get the value of id_from_scanner.
     *
     * @return string
     */
    public function getIdFromScanner()
    {
        return $this->id_from_scanner;
    }

    /**
     * Set the value of name.
     *
     * @param string $name
     * @return \App\Entities\Base\Vulnerability
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * Get the value of name.
     *
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set the value of severity.
     *
     * @param float $severity
     * @return \App\Entities\Base\Vulnerability
     */
    public function setSeverity($severity)
    {
        $this->severity = $severity;

        return $this;
    }

    /**
     * Get the value of severity.
     *
     * @return float
     */
    public function getSeverity()
    {
        return $this->severity;
    }

    /**
     * Set the value of pci_severity.
     *
     * @param float $pci_severity
     * @return \App\Entities\Base\Vulnerability
     */
    public function setPciSeverity($pci_severity)
    {
        $this->pci_severity = $pci_severity;

        return $this;
    }

    /**
     * Get the value of pci_severity.
     *
     * @return float
     */
    public function getPciSeverity()
    {
        return $this->pci_severity;
    }

    /**
     * Set the value of malware_available.
     *
     * @param boolean $malware_available
     * @return \App\Entities\Base\Vulnerability
     */
    public function setMalwareAvailable($malware_available)
    {
        $this->malware_available = $malware_available;

        return $this;
    }

    /**
     * Get the value of malware_available.
     *
     * @return boolean
     */
    public function getMalwareAvailable()
    {
        return $this->malware_available;
    }

    /**
     * Set the value of malware_description.
     *
     * @param string $malware_description
     * @return \App\Entities\Base\Vulnerability
     */
    public function setMalwareDescription($malware_description)
    {
        $this->malware_description = $malware_description;

        return $this;
    }

    /**
     * Get the value of malware_description.
     *
     * @return string
     */
    public function getMalwareDescription()
    {
        return $this->malware_description;
    }

    /**
     * Set the value of impact.
     *
     * @param string $impact
     * @return \App\Entities\Base\Vulnerability
     */
    public function setImpact($impact)
    {
        $this->impact = $impact;

        return $this;
    }

    /**
     * Get the value of impact.
     *
     * @return string
     */
    public function getImpact()
    {
        return $this->impact;
    }

    /**
     * Set the value of cvss_score.
     *
     * @param float $cvss_score
     * @return \App\Entities\Base\Vulnerability
     */
    public function setCvssScore($cvss_score)
    {
        $this->cvss_score = $cvss_score;

        return $this;
    }

    /**
     * Get the value of cvss_score.
     *
     * @return float
     */
    public function getCvssScore()
    {
        return $this->cvss_score;
    }

    /**
     * Set the value of description.
     *
     * @param string $description
     * @return \App\Entities\Base\Vulnerability
     */
    public function setDescription($description)
    {
        $this->description = $description;

        return $this;
    }

    /**
     * Get the value of description.
     *
     * @return string
     */
    public function getDescription()
    {
        return $this->description;
    }

    /**
     * Set the value of solution.
     *
     * @param string $solution
     * @return \App\Entities\Base\Vulnerability
     */
    public function setSolution($solution)
    {
        $this->solution = $solution;

        return $this;
    }

    /**
     * Get the value of solution.
     *
     * @return string
     */
    public function getSolution()
    {
        return $this->solution;
    }

    /**
     * Set the value of generic_output.
     *
     * @param string $generic_output
     * @return \App\Entities\Base\Vulnerability
     */
    public function setGenericOutput($generic_output)
    {
        $this->generic_output = $generic_output;

        return $this;
    }

    /**
     * Get the value of generic_output.
     *
     * @return string
     */
    public function getGenericOutput()
    {
        return $this->generic_output;
    }

    /**
     * Set the value of attack_type.
     *
     * @param string $attack_type
     * @return \App\Entities\Base\Vulnerability
     */
    public function setAttackType($attack_type)
    {
        $this->attack_type = $attack_type;

        return $this;
    }

    /**
     * Get the value of attack_type.
     *
     * @return string
     */
    public function getAttackType()
    {
        return $this->attack_type;
    }

    /**
     * Set the value of poc.
     *
     * @param string $poc
     * @return \App\Entities\Base\Vulnerability
     */
    public function setPoc($poc)
    {
        $this->poc = $poc;

        return $this;
    }

    /**
     * Get the value of poc.
     *
     * @return string
     */
    public function getPoc()
    {
        return $this->poc;
    }

    /**
     * Set the value of http_port.
     *
     * @param integer $http_port
     * @return \App\Entities\Base\Vulnerability
     */
    public function setHttpPort($http_port)
    {
        $this->http_port = $http_port;

        return $this;
    }

    /**
     * Get the value of http_port.
     *
     * @return integer
     */
    public function getHttpPort()
    {
        return $this->http_port;
    }

    /**
     * Set the value of published_date_from_scanner.
     *
     * @param \DateTime $published_date_from_scanner
     * @return \App\Entities\Base\Vulnerability
     */
    public function setPublishedDateFromScanner($published_date_from_scanner)
    {
        $this->published_date_from_scanner = $published_date_from_scanner;

        return $this;
    }

    /**
     * Get the value of published_date_from_scanner.
     *
     * @return \DateTime
     */
    public function getPublishedDateFromScanner()
    {
        return $this->published_date_from_scanner;
    }

    /**
     * Set the value of modified_date_from_scanner.
     *
     * @param \DateTime $modified_date_from_scanner
     * @return \App\Entities\Base\Vulnerability
     */
    public function setModifiedDateFromScanner($modified_date_from_scanner)
    {
        $this->modified_date_from_scanner = $modified_date_from_scanner;

        return $this;
    }

    /**
     * Get the value of modified_date_from_scanner.
     *
     * @return \DateTime
     */
    public function getModifiedDateFromScanner()
    {
        return $this->modified_date_from_scanner;
    }

    /**
     * Set the value of thumbnail_1.
     *
     * @param string $thumbnail_1
     * @return \App\Entities\Base\Vulnerability
     */
    public function setThumbnail1($thumbnail_1)
    {
        $this->thumbnail_1 = $thumbnail_1;

        return $this;
    }

    /**
     * Get the value of thumbnail_1.
     *
     * @return string
     */
    public function getThumbnail1()
    {
        return $this->thumbnail_1;
    }

    /**
     * Set the value of thumbnail_2.
     *
     * @param string $thumbnail_2
     * @return \App\Entities\Base\Vulnerability
     */
    public function setThumbnail2($thumbnail_2)
    {
        $this->thumbnail_2 = $thumbnail_2;

        return $this;
    }

    /**
     * Get the value of thumbnail_2.
     *
     * @return string
     */
    public function getThumbnail2()
    {
        return $this->thumbnail_2;
    }

    /**
     * Set the value of thumbnail_3.
     *
     * @param string $thumbnail_3
     * @return \App\Entities\Base\Vulnerability
     */
    public function setThumbnail3($thumbnail_3)
    {
        $this->thumbnail_3 = $thumbnail_3;

        return $this;
    }

    /**
     * Get the value of thumbnail_3.
     *
     * @return string
     */
    public function getThumbnail3()
    {
        return $this->thumbnail_3;
    }

    /**
     * Get the value of file_id.
     *
     * @return int
     */
    public function getFileId()
    {
        return $this->file_id;
    }

    /**
     * Set the value of file_id.
     *
     * @param int $file_id
     * @return Vulnerability
     */
    public function setFileId($file_id)
    {
        $this->file_id = $file_id;

        return $this;
    }

    /**
     * Set the value of created_at.
     *
     * @param \DateTime $created_at
     * @return \App\Entities\Base\Vulnerability
     */
    public function setCreatedAt($created_at)
    {
        $this->created_at = $created_at;

        return $this;
    }

    /**
     * Get the value of created_at.
     *
     * @return \DateTime
     */
    public function getCreatedAt()
    {
        return $this->created_at;
    }

    /**
     * Set the value of updated_at.
     *
     * @param \DateTime $updated_at
     * @return \App\Entities\Base\Vulnerability
     */
    public function setUpdatedAt($updated_at)
    {
        $this->updated_at = $updated_at;

        return $this;
    }

    /**
     * Get the value of updated_at.
     *
     * @return \DateTime
     */
    public function getUpdatedAt()
    {
        return $this->updated_at;
    }

    /**
     * Add Comment entity to collection (one to many).
     *
     * @param \App\Entities\Base\Comment $comment
     * @return \App\Entities\Base\Vulnerability
     */
    public function addComment(Comment $comment)
    {
        $this->comments[] = $comment;

        return $this;
    }

    /**
     * Remove Comment entity from collection (one to many).
     *
     * @param \App\Entities\Base\Comment $comment
     * @return \App\Entities\Base\Vulnerability
     */
    public function removeComment(Comment $comment)
    {
        $this->comments->removeElement($comment);

        return $this;
    }

    /**
     * Get Comment entity collection (one to many).
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getComments()
    {
        return $this->comments;
    }

    /**
     * Add JiraIssue entity to collection (one to many).
     *
     * @param \App\Entities\Base\JiraIssue $jiraIssue
     * @return \App\Entities\Base\Vulnerability
     */
    public function addJiraIssue(JiraIssue $jiraIssue)
    {
        $this->jiraIssues[] = $jiraIssue;

        return $this;
    }

    /**
     * Remove JiraIssue entity from collection (one to many).
     *
     * @param \App\Entities\Base\JiraIssue $jiraIssue
     * @return \App\Entities\Base\Vulnerability
     */
    public function removeJiraIssue(JiraIssue $jiraIssue)
    {
        $this->jiraIssues->removeElement($jiraIssue);

        return $this;
    }

    /**
     * Get JiraIssue entity collection (one to many).
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getJiraIssues()
    {
        return $this->jiraIssues;
    }

    /**
     * Add VulnerabilityReferenceCode entity to collection (one to many).
     *
     * @param \App\Entities\Base\VulnerabilityReferenceCode $vulnerabilityReferenceCode
     * @return \App\Entities\Base\Vulnerability
     */
    public function addVulnerabilityReferenceCode(VulnerabilityReferenceCode $vulnerabilityReferenceCode)
    {
        $this->vulnerabilityReferenceCodes[] = $vulnerabilityReferenceCode;

        return $this;
    }

    /**
     * Remove VulnerabilityReferenceCode entity from collection (one to many).
     *
     * @param \App\Entities\Base\VulnerabilityReferenceCode $vulnerabilityReferenceCode
     * @return \App\Entities\Base\Vulnerability
     */
    public function removeVulnerabilityReferenceCode(VulnerabilityReferenceCode $vulnerabilityReferenceCode)
    {
        $this->vulnerabilityReferenceCodes->removeElement($vulnerabilityReferenceCode);

        return $this;
    }

    /**
     * Get VulnerabilityReferenceCode entity collection (one to many).
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getVulnerabilityReferenceCodes()
    {
        return $this->vulnerabilityReferenceCodes;
    }

    /**
     * Add VulnerabilityHttpData entity to collection (one to many).
     *
     * @param VulnerabilityHttpData $vulnerabilityHttpData
     * @return \App\Entities\Base\Vulnerability
     */
    public function addVulnerabilityHttpData(VulnerabilityHttpData $vulnerabilityHttpData)
    {
        $this->vulnerabilityHttpData[] = $vulnerabilityHttpData;

        return $this;
    }

    /**
     * Remove VulnerabilityHttpData entity from collection (one to many).
     *
     * @param VulnerabilityHttpData $vulnerabilityHttpData
     * @return \App\Entities\Base\Vulnerability
     */
    public function removeVulnerabilityHttpData(VulnerabilityHttpData $vulnerabilityHttpData)
    {
        $this->vulnerabilityHttpData->removeElement($vulnerabilityHttpData);

        return $this;
    }

    /**
     * Get VulnerabilityHttpData entity collection (one to many).
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getVulnerabilityHttpData()
    {
        return $this->vulnerabilityHttpData;
    }

    /**
     * Get the related File entity (many to one).
     *
     * @return File
     */
    public function getFile()
    {
        return $this->file;
    }

    /**
     * Set the related File entity (many to one).
     *
     * @param File $file
     * @return Vulnerability
     */
    public function setFile(File $file)
    {
        $this->file = $file;

        return $this;
    }

    /**
     * Get the display name for the entity
     *
     * @param bool $plural
     * @return string
     */
    public function getDisplayName(bool $plural = false): string
    {
        return $plural === false ? 'Vulnerability' : 'Vulnerabilities';
    }

    public function __sleep()
    {
        return array('id', 'id_from_scanner', 'name', 'severity', 'pci_severity', 'malware_available', 'malware_description', 'impact', 'cvss_score', 'description', 'solution', 'generic_output', 'attack_type', 'poc', 'http_port', 'published_date_from_scanner', 'modified_date_from_scanner', 'thumbnail_1', 'thumbnail_2', 'thumbnail_3', 'file_id', 'created_at', 'updated_at');
    }
}